package com.kordar.admin.modular.sys.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.kordar.datalist.DataColumn;
import com.kordar.datalist.formatter.CreateTimeFormatter;
import com.kordar.datalist.formatter.IntegerFormatter;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@TableName("sys_datasource")
public class DatasourceEntity {

    @DataColumn
    @NotEmpty
    @Pattern(regexp = "[0-9a-zA-Z_]{6,24}", message = "用户名只能包含数字、字母和_‘下划线’组合的6-24位字符")
    @TableId(type = IdType.INPUT)
    private String name;

    @DataColumn
    @NotEmpty
    private String description;

    @DataColumn
    @NotEmpty
    private String username;

    @DataColumn
    @NotEmpty
    private String password;

    @DataColumn
    @NotEmpty
    private String url;

    @DataColumn(formatter = IntegerFormatter.class)
    private Integer active = 0;

    @DataColumn
    @NotEmpty
    private String driver;

    @DataColumn(formatter = CreateTimeFormatter.class)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
}
